home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1997 February / macformat-047.iso / Shareware Plus / Developers / PlayerPRO 4.5.3 Dev.Kit / MADH Library 4.2 / Example.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-11-11  |  3.3 KB  |  130 lines  |  [TEXT/CWIE]

  1. /********************************************************/
  2. /*
  3.     Player PRO 4.5.2 -- Music Driver EXAMPLE
  4.  
  5.     Library Version 4.02
  6.  
  7.     To use with Think C & CodeWarrior
  8.  
  9.     Antoine ROSSET
  10.     16 Tranchees
  11.     1206 GENEVA
  12.     SWITZERLAND
  13.     
  14.     FAX: (+41 22) 346 11 97
  15.     PHONE: (+41 89) 203 74 62
  16.     Email: rosset@dial.eunet.ch
  17. */
  18. /********************************************************/
  19.  
  20. #include "RDriver.h"            // Mad Driver functions & globals
  21.  
  22. /*****************************/
  23. /****** MAIN FUNCTION ********/
  24. /*****************************/
  25.  
  26. void main( void)
  27. {
  28. Boolean                End = false;
  29.  
  30. /***************                    ****************/
  31. /******          Toolbox Initialization      **********/
  32. /***************                    ****************/
  33.  
  34. InitGraf( &qd.thePort);
  35. InitFonts();
  36. InitWindows();
  37. InitMenus();
  38. TEInit();
  39. InitDialogs(0L);
  40. InitCursor();
  41. MaxApplZone();
  42. MoreMasters();
  43.  
  44. /*******************************************************************************************/
  45. /****** MAD Library Initialisation : choose the best driver for the current hardware  ******/
  46. /******                                                                                  ******/
  47. /****** Standard initialization with 4 channels...                                      ******/
  48. /*******************************************************************************************/
  49.  
  50. {
  51. MADDriverSettings    init;
  52.  
  53.  
  54. /*
  55. MANUAL DRIVER CONFIGURATION, by example:
  56.  
  57. init.numChn                = 4;
  58. init.outPutBits         = 8;
  59. init.outPutRate            = rate22khz;
  60. init.outPutMode            = StereoOutPut;
  61. init.driverMode            = SoundManagerDriver;
  62. init.antiAliasing        = false;
  63. init.repeatMusic        = false;
  64. init.Interpolation        = false;
  65. init.MicroDelay            = false;
  66. init.MicroDelaySize     = 35;
  67. init.surround             = false;
  68. init.sysMemory            = false;
  69. init.Reverb                = false;
  70. init.ReverbSize            = 45;
  71. init.ReverbStrength        = 60;
  72. init.ReverbStrength        = 60;
  73. init.TickRemover        = false;
  74. */
  75.  
  76. /* or AUTOMATIC DRIVER CONFIGURATION FOR CURRENT MAC HARDWARE*/
  77. MADGetBestDriver( &init);
  78.  
  79. if( MADInitLibrary( "\pPlugs", init.sysMemory) != noErr) DebugStr("\pSmall Problem...");
  80. if( MADCreateDriver( &init) != noErr) DebugStr("\pSmall Problem...");
  81. }
  82. /*********************************/
  83. /*********************************/
  84. /*********************************/
  85.  
  86. /****** Open a music file via Plugs ********/
  87. while( End == false)
  88. {
  89.     StandardFileReply    reply;
  90.     SFTypeList            aType;
  91.     
  92.     FlushEvents( everyEvent, 0);
  93.     
  94.     StandardGetFile( 0L, -1, aType, &reply);
  95.     
  96.     if( !reply.sfGood) End = true;
  97.     else
  98.     {
  99.         if( MADPlugAvailable( reply.sfType))        // Is available a plug to open this file?
  100.         {
  101.             if( MADImportMusicFSpFile( reply.sfType, &reply.sfFile) == noErr)        // Load this music with help of Plugs
  102.                                                                                     // in application folder, in 'Plugs' folder or internal resources
  103.             {
  104.                 MADPlay();                        // Turn interrupt driver function ON
  105.                 MADDriver->Reading = true;        // Read the current partition in memory
  106.                 
  107.                 while( !Button())
  108.                 {
  109.                     /// Do what you want here....
  110.                     /// Bla bla...
  111.                     /// By example:    Run your realtime 3D game
  112.                     ///             with 24bit texture mapping...
  113.                     
  114.                     long    fT, cT;
  115.                     
  116.                     MADGetMusicStatus( &fT, &cT);    // Some infos about current music
  117.                 }
  118.                 MADDriver->Reading = false;        // Stop reading current partition
  119.                 MADStop();                        // Stop driver interrupt function
  120.                 
  121.                 MADDisposeMusic();                // Dispose the current music
  122.                 
  123.             }
  124.         }
  125.     }
  126. }
  127. MADDisposeDriver();                        // Dispose music driver
  128. MADDisposeLibrary();                    // Close music library
  129. FlushEvents( everyEvent, 0);            // Kill your events and byebye...
  130. }